package com.cake.ssm.controller;

import com.cake.ssm.po.User;
import com.cake.ssm.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;


    @RequestMapping("/loadAllUser")
    private List<User> LoadAllUser(){
        List<User> list = null;
        try {
            list = userService.loadAllUser();
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(list);
        return list;
    }
    @RequestMapping("/LoadUser")
    public String LoadUser(Map<String,Object> map)
    {
        List<User> list = null;
        try {
            list = userService.loadAllUser();
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("第一个用户："+list.get(1));
        map.put("list",list.get(0));
        return "success";
    }

}

